#pragma once
///////////////////////////////////////////////////////////////////////////////
// Project: Hoyo Client Game
//
// game_server.h
// Created: 2013-7-15
// Author: Like Cheng
///////////////////////////////////////////////////////////////////////////////

#include "msg_server.h"
#include <boost/shared_ptr.hpp>
#include "tcp_session.h"

#define GAME_SERVER	hoyosvr::game_server::get_inst
namespace hoyosvr
{
	class game_server : public net::msg_server
	{
	public:
		typedef boost::shared_ptr<game_server>	ptr;

		static hoyosvr::game_server::ptr get_inst();
		void	async_send_to_client( int net_id, hy_network_message& m );

		static void					load_server_data();
		static void					reload_server_data();

		void						release_instance();
	private:
		void	on_init();
		void	on_update();
		void	on_stop();
		void	on_run();

		void	client_connect_handler	(tcp_session_ptr session,int error_value);

		void	sync_process_recv_msg(int net_id,hy_network_message::ptr recv_msg_ptr);
		bool	async_process_recv_msg(tcp_session_ptr conn,hy_network_message::ptr recv_msg_ptr);

		int		_updateTime;
	};
}
